package com.wuyangnju.healthclub.service;

import java.util.List;

import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.wuyangnju.healthclub.dao.SingleDao;
import com.wuyangnju.healthclub.entity.Single;

@Component
public class SingleService {

	@PersistenceContext
	protected EntityManager em;

	@Resource
	private SingleDao singlePersonDao;

	@Transactional
	public Single get(String cardId) {
		return singlePersonDao.retrieve(em, Long.valueOf(cardId));
	}

	@Transactional
	public List<Single> get() {
		return singlePersonDao.retrieve(em);
	}

	@Transactional
	public String post(Single single) {
		singlePersonDao.create(em, single);
		return single.getCardId();
	}

	@Transactional
	public void put(Single single) {
		singlePersonDao.update(em, single.getId(), single);
	}

	@Transactional
	public void delete(Single single) {
		singlePersonDao.delete(em, single.getId());
	}
}
